//
//  PickUpDetailsViewController.m
//  BaseFrame
//
//  Created by 吕金状 on 2017/8/10.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "PickUpDetailsViewController.h"
#import "PickUpDetailsTableViewCell.h"
#import "PrCodeView.h"
#import "QrCodeWebView.h"

@interface PickUpDetailsViewController ()<UITableViewDelegate , UITableViewDataSource>

Strong UITableView *tableView;
Strong NSMutableArray *dataArray; /**<*/

@end

@implementation PickUpDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"取件详情";
    
    self.dataArray[0][@"content"] = self.dataDictonary[@"address"];//所在位置
    self.dataArray[1][@"content"] = self.dataDictonary[@"pickup_password"];//取件口令
    self.dataArray[2][@"content"] = self.dataDictonary[@"lo_type"];//物品类型
    //self.dataArray[3][@"content"] = self.dataDictonary[@"lo_number"];//物品编号
    self.dataArray[3][@"content"] = self.dataDictonary[@"guest_book"];//内容说明
    //self.dataArray[4][@"content"] = self.dataDictonary[@"pickup_code"];//取件二维码
    [self.view addSubview:self.tableView];
}

#pragma mark - init

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorInset = UIEdgeInsetsZero;
        if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
            [_tableView setLayoutMargins:UIEdgeInsetsZero];
        }
        _tableView.sectionFooterHeight = .01;
        _tableView.sectionHeaderHeight = .01;
        _tableView.tableFooterView = [UIView new];
        _tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0.01)];
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.backgroundColor = getColor(@"ffffff");
    }
    return _tableView;
}


#pragma mark - <UITableViewDelegate , UITableViewDataSource>

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PickUpDetailsTableViewCell *cell = [PickUpDetailsTableViewCell cellForTableView:tableView];
    cell.indexPath = indexPath;
    cell.model = self.dataArray[indexPath.row];
    //cell.accessoryType = indexPath.row == 3 ?  UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 4) {
        /*
        PrCodeView *view = [[PrCodeView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        view.nameString = self.dataDictonary[@"pickup_code"];
        [view show];
         */
        
        QrCodeWebView *view = [[QrCodeWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        view.nameString = [NSString stringWithFormat:@"%@",self.dataDictonary[@"pickup_code"]];
        [view show];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60 / WIDTH_5S_SCALE + 0.5;
}

#pragma mark - data

- (NSMutableArray *)dataArray{
    if (!_dataArray) {
        _dataArray  = @[
                        @{@"image":@"address",@"title":@"所在位置",@"content":@"地址"}.mutableCopy,
                        @{@"image":@"TakeThePassword",@"title":@"取件口令",@"content":@"1234"}.mutableCopy,
                        @{@"image":@"ItemType",@"title":@"物品类型",@"content":@"信息"}.mutableCopy,
                        //@{@"image":@"ItemNumber",@"title":@"物品编号",@"content":@"地址息信息"}.mutableCopy,
                        @{@"image":@"ItemContent",@"title":@"内容说明",@"content":@"地息地址信息"}.mutableCopy,
                        @{@"image":@"prCode",@"title":@"取件二维码",@"content":@"点击查看"}.mutableCopy
                        ].mutableCopy;
    }
    return _dataArray;
}


@end
